﻿// <copyright project="Salient.SqlServer" file="DatabaseFixture.cs" company="Sky Sanders">
// This source is a Public Domain Dedication.
// Please see http://spikes.codeplex.com/ for details.   
// Attribution is appreciated
// </copyright> 
// <version>1.0</version>
using System;
using System.Collections.Specialized;
using Salient.SqlServer.Management;

namespace Salient.SqlServer.Testing
{
    public abstract class DatabaseFixture : Database
    {
        private readonly StringCollection _scripts = new StringCollection();
        private int _uuid;


        protected DatabaseFixture(string dataSource, string initialCatalog)
            : base(dataSource, initialCatalog)
        {
        }

        protected DatabaseFixture(string dataSource, string initialCatalog, string userId, string password)
            : base(dataSource, initialCatalog, userId, password)
        {
        }

        protected DatabaseFixture(string connectionString)
            : base(connectionString)
        {
        }

        protected StringCollection Scripts
        {
            get { return _scripts; }
        }

        protected int NextId()
        {
            return ++_uuid;
        }

        protected static int TI()
        {
            return Environment.TickCount;
        }

        protected static decimal TD()
        {
            return Environment.TickCount;
        }

        protected static string TS()
        {
            return Environment.TickCount.ToString();
        }

        public virtual void TestFixtureSetUp()
        {
            DropAndCreate(_scripts);
        }


        public virtual void TestFixtureTearDown()
        {
            Drop();
        }
    }
}